home *** CD-ROM | disk | FTP | other *** search
/ OpenGL Superbible (2nd Edition) / OpenGL SuperBible e2.iso / book / Chap06 / MATLIGHT / LIGHTEDITOR.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-27  |  2.2 KB  |  88 lines

  1. // LightEditor.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "matlight.h"
  6.  
  7. #include "MainFrm.h"
  8. #include "matlight.h"
  9. #include "LightEditor.h"
  10.  
  11. #ifdef _DEBUG
  12. #define new DEBUG_NEW
  13. #undef THIS_FILE
  14. static char THIS_FILE[] = __FILE__;
  15. #endif
  16.  
  17. /////////////////////////////////////////////////////////////////////////////
  18. // CLightEditor
  19.  
  20. IMPLEMENT_DYNAMIC(CLightEditor, CPropertySheet)
  21.  
  22. // This constructor is not used
  23. CLightEditor::CLightEditor(UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage)
  24.     :CPropertySheet(nIDCaption, pParentWnd, iSelectPage)
  25. {
  26. }
  27.  
  28. // We are only using this one
  29. CLightEditor::CLightEditor(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage)
  30.     :CPropertySheet(pszCaption, pParentWnd, iSelectPage)
  31. {
  32. m_pAmbientPage = new CEditor(IDD_EDITOR,IDS_AMBIENT);
  33. m_pDiffusePage = new CEditor(IDD_EDITOR,IDS_DIFFUSE);
  34. m_pSpecularPage = new CEditor(IDD_EDITOR,IDS_SPECULAR);
  35. AddPage(m_pAmbientPage);
  36. AddPage(m_pDiffusePage);
  37. AddPage(m_pSpecularPage);
  38. }
  39.  
  40. CLightEditor::~CLightEditor()
  41. {
  42. delete m_pSpecularPage;
  43. delete m_pDiffusePage;
  44. delete m_pAmbientPage;
  45. }
  46.  
  47.  
  48. BEGIN_MESSAGE_MAP(CLightEditor, CPropertySheet)
  49.     //{{AFX_MSG_MAP(CLightEditor)
  50.         // NOTE - the ClassWizard will add and remove mapping macros here.
  51.     //}}AFX_MSG_MAP
  52.     ON_MESSAGE(WM_UPDATE,updateFunc)
  53. END_MESSAGE_MAP()
  54.  
  55. /////////////////////////////////////////////////////////////////////////////
  56. // CLightEditor message handlers
  57.  
  58. BOOL CLightEditor::OnInitDialog() 
  59.     {
  60.     m_pAmbientPage->SetValues(m_pDocumentPointer->fLight0Ambient);
  61.     m_pDiffusePage->SetValues(m_pDocumentPointer->fLight0Diffuse);
  62.     m_pSpecularPage->SetValues(m_pDocumentPointer->fLight0Specular);
  63.  
  64.     m_pAmbientPage->m_pParent = this;
  65.     m_pDiffusePage->m_pParent = this;
  66.     m_pSpecularPage->m_pParent = this;
  67.  
  68.     return CPropertySheet::OnInitDialog();
  69.     }
  70.  
  71. LONG CLightEditor::updateFunc(UINT, LONG)
  72.     {
  73.     // Pull the values and update the document
  74.     m_pAmbientPage->GetValues(m_pDocumentPointer->fLight0Ambient);
  75.     m_pDiffusePage->GetValues(m_pDocumentPointer->fLight0Diffuse);
  76.     m_pSpecularPage->GetValues(m_pDocumentPointer->fLight0Specular);
  77.     m_pDocumentPointer->UpdateAllViews(NULL,0,NULL);
  78.  
  79.  
  80.     
  81.     return 0L;
  82.     }
  83.  
  84.  
  85. void CLightEditor::Update()
  86.     {
  87.     updateFunc(0,0);
  88.     }